Skip to content

fix(transient-render-engine): preserve nested inline boundary spaces#34

Open
leineveber wants to merge 1 commit intonative-html:mainfrom
leineveber:fix/nested-inline-whitespace
Open

fix(transient-render-engine): preserve nested inline boundary spaces#34
leineveber wants to merge 1 commit intonative-html:mainfrom
leineveber:fix/nested-inline-whitespace

Conversation

@leineveber
Copy link
Copy Markdown

Summary

Fix whitespace collapsing for nested inline phrasing nodes so boundary spaces inside named inline wrappers like span are preserved until the parent phrasing node collapses sibling whitespace correctly.

Adds a regression test for nested inline tags that previously rendered foo bar as foobar.

Closes #33

Keep boundary spaces inside named inline wrappers until the parent
phrasing node collapses sibling whitespace.

Add a regression test for nested inline tags that previously rendered
"foobar" instead of "foo bar".

Made-with: Cursor
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (5636b6e) to head (b2f8f02).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   98.65%   98.65%           
=======================================
  Files         140      140           
  Lines        2083     2084    +1     
  Branches      633      634    +1     
=======================================
+ Hits         2055     2056    +1     
  Misses         27       27           
  Partials        1        1           
Flag Coverage Δ
css-processor 100.00% <ø> (ø)
render 97.84% <ø> (ø)
transient-render-engine 98.95% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@5ZYSZ3K
Copy link
Copy Markdown
Collaborator

5ZYSZ3K commented Apr 13, 2026

Hi @leineveber, thanks for the contribution!
I'll take a look at that quickly - code seems to be fine, I just want to check it against browser behaviour, I can't tell from the top of my head whether that was a bug or a feature

Comment on lines +40 to +52
it('should preserve boundary spaces wrapped in nested inline phrasing tags', () => {
const ttree = makeTTree(
'<span><span><strong>foo</strong> </span><span><strong>bar</strong></span></span>'
);
const [firstSpan, secondSpan] = ttree.children;
expect(firstSpan.tagName).toBe('span');
expect(firstSpan.children).toHaveLength(2);
expect((firstSpan.children[0] as TTextImpl).data).toBe('foo');
expect((firstSpan.children[1] as TTextImpl).data).toBe(' ');
expect(secondSpan.tagName).toBe('span');
expect(secondSpan.children).toHaveLength(1);
expect((secondSpan.children[0] as TTextImpl).data).toBe('bar');
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use a snaphot, like every other test in this file.

Copy link
Copy Markdown
Contributor

@jsamr jsamr Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a test that proves that two spaces are still collapsed into one. In other words

the following:

<span><span><strong>foo</strong>  </span><span><strong>bar</strong></span></span>

renders the same as your example:

<span><span><strong>foo</strong> </span><span><strong>bar</strong></span></span>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Whitespace collapsing trims spaces too early in nested inline phrasing nodes

3 participants